package d0309;

    import javax.swing.*;

    public abstract class Shape {
        public abstract void area();
        public abstract void perimeter();
    }

    class Rectangle extends Shape{
        double length;
        double wide;
        public Rectangle(double length,double wide){
            this.length=length;
            this.wide=wide;
        }
        public void area(){
            System.out.println("矩形面积："+length*wide);
        }
        public void perimeter(){
            System.out.println("矩形周长："+(length+wide)*2);
        }

        public static void main(String[] args) {
            Rectangle rectangle=new Rectangle(3,4);
            rectangle.area();
            rectangle.perimeter();
        }
    }

    class Triangle extends Shape{
        double side1;
        double side2;
        double baseside;
        double height;
        public Triangle(double side1,double side2,double baseside,double height){
            this.side1=side1;
            this.side2=side2;
            this.baseside=baseside;
            this.height=height;
        }
        public void area(){
            System.out.println("三角形面积："+baseside*height/2);
        }
        public void perimeter(){
            System.out.println("三角形周长："+(side1+side2+baseside));
        }

        public static void main(String[] args) {
            Triangle triangle=new Triangle(6,8,10,4.8);
            triangle.area();
            triangle.perimeter();
        }

    }

    class Circle extends Shape{
        double radius;
        public Circle(double radius){
            this.radius=radius;
        }
        public void area(){
            System.out.println("圆形面积："+radius*radius*3.14);
        }
        public void perimeter(){
            System.out.println("圆形周长："+radius*2*3.14);
        }

        public static void main(String[] args) {
            Circle circle=new Circle(3);
            circle.area();
            circle.perimeter();
        }
    }

